﻿// CUserCheckDlg.cpp: 实现文件
//

#include "pch.h"
#include "ProjectAA.h"
#include "CUserCheckDlg.h"
#include "afxdialogex.h"


// CUserCheckDlg 对话框

IMPLEMENT_DYNAMIC(CUserCheckDlg, CDialogEx)

CUserCheckDlg::CUserCheckDlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_DIALOG_USER, pParent)
	, User(_T(""))
{

}

CUserCheckDlg::~CUserCheckDlg()
{
}

void CUserCheckDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT1, User);
}


BEGIN_MESSAGE_MAP(CUserCheckDlg, CDialogEx)
	ON_BN_CLICKED(IDOK, &CUserCheckDlg::OnBnClickedOk)
	ON_BN_CLICKED(IDCANCEL, &CUserCheckDlg::OnBnClickedCancel)
END_MESSAGE_MAP()


// CUserCheckDlg 消息处理程序


BOOL CUserCheckDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	ReadConfigIni();

	return TRUE;  
}


void CUserCheckDlg::OnCancel()
{
	CDialogEx::OnCancel();
}

void CUserCheckDlg::ReadConfigIni()
{
	User = gSystemMgr.UserMsg;
	UpdateData(FALSE);
}

void CUserCheckDlg::SaveValueToConfig()
{
	UpdateData(TRUE);

	gSystemMgr.UserMsg = User;

	CString cstr;

	gSystemMgr.m_cLoginConfigIni.SaveConfigIni(L"Login", L"UserMsg", gSystemMgr.UserMsg);

	gSystemLog.DisplayLogAndSave(L"操作员保存数据完成", LV_EVENT);
}


void CUserCheckDlg::OnBnClickedOk()
{
	SaveValueToConfig();
	CDialogEx::OnCancel();
}


void CUserCheckDlg::OnBnClickedCancel()
{
	CDialogEx::OnCancel();
}
